Programming iOS 10 by Matt Neuburg
Author:Matt Neuburg
Language: eng
Format: epub
Publisher: O'Reilly Media
Published: 2016-11-25T05:00:00+00:00
Deal with the table’s appearance. If we deleted the section array, we’ll call deleteSections (and reload the section index if there is one); otherwise, we’ll call deleteRows.
That’s the strategy; here’s the implementation:
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt ip: IndexPath) { self.cellData[ip.section].remove(at:ip.row) if self.cellData[ip.section].count == 0 { self.cellData.remove(at:ip.section) self.sectionNames.remove(at:ip.section) tableView.deleteSections( IndexSet(integer: ip.section), with:.automatic) tableView.reloadSectionIndexTitles() } else { tableView.deleteRows(at:[ip], with:.automatic) } }
The user can also delete a row by sliding it to the left to show its Delete button without having explicitly entered edit mode; no other row is editable, and no other editing controls are shown. This feature is implemented “for free” by virtue of our having supplied an implementation of tableView(_:commit:forRowAt:).
If you’re like me, your first response will be: “Thanks for the free functionality, Apple, and now how do I turn this off?” Because the Edit button is already using the UIViewController’s isEditing property to track edit mode, we can take advantage of this and refuse to let any cells be edited unless the view controller is in edit mode:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6532)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6409)
Kotlin in Action by Dmitry Jemerov(5062)
Odoo 15 Development Essentials - Fifth Edition by Daniel Reis & Greg Mader(3330)
Odoo 15 Development Essentials by Daniel Reis(2811)
React Native - Building Mobile Apps with JavaScript by Novick Vladimir(2526)
Learning Angular - Second Edition by Christoffer Noring(2355)
Pride and Prejudice by Jane Austen(2346)
Mobile Forensics Cookbook by Igor Mikhaylov(2014)
Computers For Seniors For Dummies by Nancy C. Muir(1995)
Bulletproof Android: Practical Advice for Building Secure Apps (Developer's Library) by Godfrey Nolan(1868)
Android Development with Kotlin by Marcin Moskala & Igor Wojda(1794)
Building Android UIs with Custom Views by Raimon Ràfols Montané(1786)
1936941139 (N) by Bob Rosenthal(1731)
Building Progressive Web Apps: Bringing the Power of Native to the Browser by Ater Tal(1722)
Hands-On Internet of Things with MQTT by Tim Pulver(1704)
Android App Development by Franceschi Hervé J.;(1702)
Ember.js in Action by Joachim Haagen Skeie(1686)
Hands-On Design Patterns with React Native by Mateusz Grzesiukiewicz(1652)
